/*
-----------------------------------------------------------------------------
Filename:    SpaceProject.h
-----------------------------------------------------------------------------
*/
#ifndef __SpaceProject_h_
#define __SpaceProject_h_

#include <OGRE/Ogre.h>

// vrpn Server
#include "vrpn_Button.h"
#include "vrpn_Tracker.h"
#include "vrpn_Analog.h"

// Menu CEGUI
#include "menuCEGUI.h"

// Collision System
#include "CollisionTools.h"

// OpenAL sound
#include "SoundManager.h"

// Ship and Enemy Class
#include "Ship.h"
#include "Enemy.h"

class SpaceProject : public menuCEGUI
{
public:
	SpaceProject(void);
	virtual ~SpaceProject(void);
	
protected:
	virtual void createScene(void);
	virtual bool frameRenderingQueued(const Ogre::FrameEvent& evt);

	// Setup Scene
	void setupScenario(void);
	void setupVRPN(void);
	void setupSound(void);
	void setupParticles(void);

	// OIS::KeyListener
	virtual bool keyPressed( const OIS::KeyEvent &arg );
	virtual bool keyReleased( const OIS::KeyEvent &arg );

	// players
	Ship* Player1;
	Ship* Player2;	

	// Enemys
	Enemy** Enemies;
	int nEnemies;
	void hitEnemies(void);

	// count laps
	Ogre::Plane goalPlane;			// plane for the finish
	void countLaps(void);

	// count speeds
	void countSpeed(void);

	// check who win
	void checkVictory(void);

	// *** MOC Setup *** Collision
	MOC::CollisionTools* mCollisionTools;	
	
	// Sound system
	SoundManager* mSoundMgr;
	bool processSound(const Ogre::FrameEvent& evt);
	unsigned int shootSound , flameSound, acelerateSound, ambientMusic, checkinSound, zombieSound;

	// Vrpn
private:
	// Iotracker
	bool processIotrackerInput(const Ogre::FrameEvent& evt);

	static void VRPN_CALLBACK handleIotracker(void* userData, const vrpn_TRACKERCB t);
	vrpn_Tracker_Remote* iotracker;
	vrpn_TRACKERCB data;

	static void VRPN_CALLBACK handle_iotracker_Button(void* userData, const vrpn_BUTTONCB b);
	vrpn_Button_Remote* iotrackerButton;

	// joystick
	static void VRPN_CALLBACK handle_joystick_analog(void* userData, const vrpn_ANALOGCB a);
	vrpn_Analog_Remote* joystickAnalog;
	static void VRPN_CALLBACK handle_joystick_Button(void* userData, const vrpn_BUTTONCB b);
	vrpn_Button_Remote* joystickButton;

	// gamepad
	static void VRPN_CALLBACK handle_gamepad_analog(void* userData, const vrpn_ANALOGCB a);
	vrpn_Analog_Remote* gamepadAnalog;
	static void VRPN_CALLBACK handle_gamepad_Button(void* userData, const vrpn_BUTTONCB b);
	vrpn_Button_Remote* gamepadButton;

	// target for vrpn
	Ogre::SceneNode* targetNode;

	// control input device
};

#endif // #ifndef __Zproyect_h_
